home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades reversed ƒ / Rescue Raiders fade reversed.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  101 lines

  1. /**********************************************************************\
  2.  
  3. File:        Rescue Raiders fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 5
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short RescueRaidersFadeReversed(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* One region in 8 parts.  Each part of the region either starts at a corner
  34.    or in the middle of a side and moves progressively counterclockwise until the
  35.    entire screen is filled. Named after a similar effect in the game Rescue
  36.    Raiders on the Apple ][e (now called Armor Alley™ on the Mac, but it doesn't
  37.    have this effect in it anymore). */
  38.    
  39. pascal short RescueRaidersFadeReversed(Rect boundsRect, Pattern *thePattern)
  40. {
  41.     RgnHandle    curregion;
  42.     int            cx,cy,lastx,lasty;
  43.     int            BlockSize, VBlockSize;
  44.     
  45.     cx = theWindowWidth / 2;
  46.     cy = theWindowHeight / 2;
  47.     BlockSize=theWindowWidth/25;
  48.     VBlockSize=theWindowHeight/25;
  49.  
  50.     lastx=cx-BlockSize;
  51.     lasty=cy-VBlockSize;
  52.     curregion=NewRgn();
  53.     do
  54.     {
  55.         StartTiming();
  56.  
  57.         SetEmptyRgn(curregion);
  58.         MoveTo(cx,cy);
  59.         OpenRgn();
  60.             LineTo(lastx,0);
  61.             Line(BlockSize,0);
  62.             LineTo(theWindowWidth-lastx-BlockSize,theWindowHeight);
  63.             Line(BlockSize,0);
  64.             LineTo(cx,cy);
  65.             
  66.             LineTo(cx+lastx,0);
  67.             Line(BlockSize,0);
  68.             LineTo(cx-lastx-BlockSize,theWindowHeight);
  69.             Line(BlockSize,0);
  70.             LineTo(cx,cy);
  71.             
  72.             LineTo(theWindowWidth,lasty);
  73.             Line(0,VBlockSize);
  74.             LineTo(0,theWindowHeight-lasty-VBlockSize);
  75.             Line(0,VBlockSize);
  76.             LineTo(cx,cy);
  77.             
  78.             LineTo(theWindowWidth,cy+lasty);
  79.             Line(0,VBlockSize);
  80.             LineTo(0,cy-lasty-VBlockSize);
  81.             Line(0,VBlockSize);
  82.             LineTo(cx,cy);
  83.         CloseRgn(curregion);
  84.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  85.         
  86.         FillRgn(curregion, *thePattern);
  87.  
  88.         lastx-=BlockSize;
  89.         lasty-=VBlockSize;
  90.  
  91.         TimeCorrection(CorrectTime);
  92.     }
  93.     while (lastx>=0);
  94.     
  95.     FillRect(&boundsRect, *thePattern);        /* in case we missed any bits */
  96.     
  97.     DisposeRgn(curregion);
  98.     
  99.     return 0;
  100. }
  101.